<?php
     include_once('../src/classes/class.mysql.php');  
     session_start();
     $db = new MySQL();
     $comtec_id_mainteiner = $_GET['id'];
     
     function extra($x){
      if ($x <= 9){
       $x = "0".$x;   
      }   
      return $x;   
     }
?>
  
<fieldset class="curved">
 <legend>Buscar</legend>
  <table style="border-spacing: 10px;">      
   <tr>
       <td width="200">Fecha desde</td>
       <td>
           <?
             $optionsXML = simplexml_load_file("../xml/days.xml"); 
             $options =  $optionsXML->xpath("//day/text()");
             echo '<select id="day1_b">';
             while(list( $key , $value) = each($options)) {
              echo '<option value='.extra($key).'>' . $value . '</option>';
             }
             echo '</select>';
          ?>
          <?
            $optionsXML = simplexml_load_file("../xml/months.xml"); 
            $options =  $optionsXML->xpath("//month/text()");
            echo '<select id="month1_b">';
            while(list( $key , $value) = each($options)) {  
             echo '<option value='.extra($key).'>' . $value . '</option>';
            }
            echo '</select>';
          ?>
          <?
            $optionsXML = simplexml_load_file("../xml/years.xml"); 
            $options =  $optionsXML->xpath("//year/text()");
            echo '<select id="year1_b">';
            while(list($key,$value) = each($options)) {   
             echo '<option value='.$value.'>' . $value . '</option>';
            }
            echo '</select>';
          ?>   
       </td>
       <td width="200">Fecha hasta</td>
       <td>
          <?
             $optionsXML = simplexml_load_file("../xml/days.xml"); 
             $options =  $optionsXML->xpath("//day/text()");
             echo '<select id="day2_b">';
             while(list( $key , $value) = each($options)) {
              echo '<option value='.extra($key).'>' . $value . '</option>';
             }
             echo '</select>';
          ?>
          <?
            $optionsXML = simplexml_load_file("../xml/months.xml"); 
            $options =  $optionsXML->xpath("//month/text()");
            echo '<select id="month2_b">';
            while(list( $key , $value) = each($options)) {  
             echo '<option value='.extra($key).'>' . $value . '</option>';
            }
            echo '</select>';
          ?>
          <?
            $optionsXML = simplexml_load_file("../xml/years.xml"); 
            $options =  $optionsXML->xpath("//year/text()");
            echo '<select id="year2_b">';
            while(list($key,$value) = each($options)) {   
             echo '<option value='.$value.'>' . $value . '</option>';
            }
            echo '</select>';
          ?>  
       </td>
   </tr>
   <tr>
       <td width="200">Tipo de operaci&oacute;n</td>
       <td>
           <select id="operation_type_b">
            <option value="0" selected> - </option>
            <option value="1">Mantenci&oacute;n</option>
            <option value="2">Emergencia</option>
            <option value="3">Instalaci&oacute;n</option>
            <option value="4">Reparaci&oacute;n</option>
           </select>
       </td>
       <? if($_SESSION['users']!="clients"){ ?>
       <td width="200">Encargado</td>
       <td>
           <select id="comtec_id_responsible_b">
                    <option value="0" selected> - </option>
                    <?
                        $responsible = $db->query("SELECT comtec_id_responsible, name, lastname1, lastname2, status_reg FROM responsible WHERE comtec_id_mainteiner = $comtec_id_mainteiner ");
                        while ($r = mysql_fetch_array($responsible, MYSQL_ASSOC))
                        {
                         if ($r['status_reg'] == 1)
                         {
                          echo "<option value=".$r['comtec_id_responsible'].">".$r['name']." ".$r['lastname1']." ".$r['lastname2']."</option>";
                         }
                        }
                    ?>
            </select>
       </td>
       <? } ?>
   </tr>
   <tr>
       <? if($_SESSION['users'] != "clients"){ ?>
       <td width="200">Propietario</td>
       <td>
         <input type="text" id="owner_b" /> 
       </td>
       <? }?>
       <td width="200">M&aacute;quina</td>
       <td>
         <input type="text" id="machine_b" />
       </td>  
   </tr>
   <tr>
       <td width="200">Tipo</td>
       <td>
           <select id="type_b">
            <option value="1" selected>Operaciones</option>
            <option value="2">Ordenes de trabajo</option>
           </select>
       </td>
   </tr>    
   <tr>
       <td><input type="button" value="Buscar" onclick="javascript:searchOperations();" /></td> 
   </tr>
   </table>
   <div id="result_b"></div>
</fieldset>
  
  <div id="resultList"></div>
  

